<template>
	<view class="container">
		<view class="comment">
			<view v-for="(item, index) in datalist" :key="index" class="item">
				<view class=" nameBox">
					<view>
						<image style="width:80rpx;height: 80rpx;border-radius: 50%;" :src="item.headimg" />
					</view>
					<view class="t2" style="overflow: hidden;margin-right: 40rpx;">{{item.nickname}}</view>
					<view class="t3">
						<uni-rate :readonly="true" :value="item.score" :margin="10" color="#bbb" active-color="red"
							size="16" margin='4' />
					</view>
				</view>
				<view style="color:#777;font-size:22rpx;">{{item.createtime}}</view>
				<view class="f2">
					<text class="t1">{{item.content}}</text>
					<view class="t2">
						<block v-if="item.content_pic!=''">
							<block v-for="(itemp, index) in item.content_pic" :key="index">
								<view >
									<image :src="itemp" mode="widthFix" @click="previewImage(item.content_pic,index)" />
								</view>
							</block>
						</block>
					</view>
					<text class="t3">规格：{{item.ggname}}</text>
				</view>
				<view class="f3" v-if="item.reply_content">
					<view class="arrow"></view>
					<view class="t1">商家回复：{{item.reply_content}}</view>
				</view>
			</view>
			<view class="flex-center addressImgBox" v-if="datalist.length==0">
				<image class="norMoreImg" src="https://wx.2024csnl.com/static/noData.png"></image>
				暂无评论~
			</view>
			<view style="text-align: center;color: #999;" v-if="noMoreData&&datalist.length!=0">没有更多啦~</view>
		</view>
	</view>
</template>

<script>
	import {
		goodsComment
	} from "../../api/index.js"

	export default {
		data() {
			return {
				proid: '',
				pagenum: 1,
				datalist: [],
				noMoreData: false,
			};
		},

		onLoad(opt) {
			this.proid = opt.proid
			this.getdata();
		},
		onReachBottom() {
			this.pagenum += 1
			this.getdata('bottom')
		},
		methods: {
			previewImage(imgList, i) {
				uni.previewImage({
					urls: imgList,
					current: i,
				})
			},
			async getdata(type) {
				const res = await goodsComment('s=/ApiShop/commentlist', {
					proid: this.proid,
					pagenum: this.pagenum
				})
				const {
					status,
					msg,
					data
				} = res.data
				if (status == 1) {
					type == 'bottom' ? this.datalist.push(...data) : this.datalist = data
					this.pagenum != 1 && data.length == 0 ? this.noMoreData = true : this.noMoreData = false
				} else {
					this.showToast(msg)
				}
			}
		}
	};
</script>

<style lang="less">
	page {
		background-color: #f8f8f8;
	}

	.addressImgBox {
		flex-direction: column;
		margin-top: 200rpx;
		color: #999;
		padding-top: 20%;
	}

	.norMoreImg {
		width: 300rpx;
		height: 300rpx;
	}

	.container {
		background: #fff
	}

	.comment {
		display: flex;
		flex-direction: column;
		padding: 10rpx 0;
	}

	.comment .item {
		border-bottom: 10rpx solid #f8f8f8;
		padding: 10rpx 20rpx;
		display: flex;
		flex-direction: column;
	}

	.comment .item .f1 {
		display: flex;
		width: 100%;
		align-items: center;
		padding: 10rpx 0;
	}

	.comment .item .f1 .t1 {
		width: 70rpx;
		height: 70rpx;
		border-radius: 50%;
	}

	.comment .item .f1 .t2 {
		padding-left: 10rpx;
		color: #333;
		font-weight: bold;
		font-size: 30rpx;
	}

	.comment .item .f1 .t3 {
		text-align: right;
	}

	.comment .item .f1 .t3 .img {
		width: 24rpx;
		height: 24rpx;
		margin-left: 10rpx
	}

	.comment .item .score {
		font-size: 24rpx;
		color: #f99716;
	}

	.comment .item .score image {
		width: 140rpx;
		height: 50rpx;
		vertical-align: middle;
		margin-bottom: 6rpx;
		margin-right: 6rpx;
	}

	.comment .item .f2 {
		display: flex;
		flex-direction: column;
		width: 100%;
		padding: 10rpx 0;
	}

	.comment .item .f2 .t1 {
		color: #333;
		font-size: 28rpx;
	}

	.comment .item .f2 .t2 {
		display: flex;
		width: 100%
	}

	.comment .item .f2 .t2 image {
		width: 100rpx;
		height: 100rpx;
		margin: 10rpx;
	}

	.comment .item .f2 .t3 {
		color: #aaa;
		font-size: 24rpx;
	}

	.comment .item .f2 .t3 {
		color: #aaa;
		font-size: 24rpx;
	}

	.comment .item .f3 {
		width: 100%;
		padding: 10rpx 0;
		position: relative
	}

	.comment .item .f3 .arrow {
		width: 16rpx;
		height: 16rpx;
		background: #eee;
		transform: rotate(45deg);
		position: absolute;
		top: 0rpx;
		left: 36rpx
	}

	.comment .item .f3 .t1 {
		width: 100%;
		border-radius: 10rpx;
		padding: 10rpx;
		font-size: 22rpx;
		color: #888;
		background: #eee
	}

	.nameBox {
		display: grid;
		width: 100vw;
		align-items: center;
		grid-template-columns: 12vw 57vw 40vw;

		image {
			width: 100rpx;
			height: 100rpx;
		}
	}
</style>
